package com.wzy.vx.controller;

import com.wzy.vx.service.SecKillService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName: vx
 * @Package: com.wzy.vx.controller
 * @ClassName: SecKillController
 * @Author: Administrator
 * @Description: ${秒杀页面}
 * @Date: 2019/3/26 11:39
 * @Version: 1.0
 */
@RestController
@RequestMapping("/skill")
public class SecKillController  {
    private final  static Logger  log = LoggerFactory.getLogger(SecKillController.class);

    @Autowired
    private SecKillService secKillService;

    /**
     * 查询秒杀活动特价商品的信息
     */
    @GetMapping("/query/{productId}")
    public String query(@PathVariable String productId)throws Exception
    {
        return secKillService.querySecKillProductInfo(productId);
    }


    /**
     * 秒杀，没有抢到获得""不是单身贵族",如果抢到了,会返回剩余的库存量
     */
    @GetMapping("/order/{productId}")
    public String skill(@PathVariable String productId)throws Exception
    {
        log.info("@skill request, productId:" + productId);
        secKillService.orderProductMockDiffUser(productId);
        return secKillService.querySecKillProductInfo(productId);
    }
}
